package org.dr.springmvcdemo.getparam;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 获取单个参数
 * 获取多个参数
 */
@RestController
@RequestMapping("/param")
public class ParamController

{
    //获取单个参数
    /**
     * postman 测试key=”name与method_1中String类型的那么对应
     * @param name
     * @return
     */
    @RequestMapping("/m1")
    public Object method_1(String name){
        System.out.println("参数name"+name);
        return "获取单个参数名称："+name;
    }

    /**
     * @param name
     * 实际在postman中请求的参数key="username"
     * @return
     */
    @RequestMapping("/m11")
    public Object method_11(@RequestParam("username") String name){
        System.out.println("参数name"+name);
        return "获取单个参数名称："+name;
    }

    /**
     * 获取多个参数
     * 获取参数name与password
     * @param name
     * @param password
     * @return
     */
    @RequestMapping("/m2")
    public Object method_2(String name,String password){
        System.out.println("参数name"+name);
        System.out.println("参数password"+password);
        return "获取多个参数名称："+name+" "+password;
    }

}
